﻿using System;
using System.Windows.Forms;
using DXApplicationTangche.UC.项目成果管理.service;
using DXApplicationTangche.UC.生产计划.生产批生产.service;
using DXApplicationTangche.UC.下单MTO.Service;
using DXApplicationTangche.UC.流程.Service;
using DXApplicationTangche.UC.门店出入库.Service;
using DXApplicationTangche.UC.套号管理.套号下单;
using DXApplicationTangche.UC.成品出库单.service;

namespace DXApplicationTangche.UC.流程
{
    public partial class Form条码报废处置 : DevExpress.XtraEditors.XtraForm
    {
        private String barcode { get; set; }

        public Form条码报废处置(String barcode)
        {
            InitializeComponent();
            this.barcode = barcode;
        }

        private void textBox扫描_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 13)
            {
                if (String.IsNullOrEmpty(this.textBox扫描.Text))
                {
                    MessageBox.Show("无扫描信息");
                    return;
                }
                //判断扫描的工牌是否正确
                String mnemonic = 项目成果Service.get判断扫描员工码是否正确(this.textBox扫描.Text.Trim());
                if (String.IsNullOrWhiteSpace(mnemonic))
                {
                    this.textBox扫描.Clear();
                    MessageBox.Show("扫描员工码错误，请重新扫描");
                    return;
                }
                try
                {
                    //报废处置
                    StockInOutDetailDTO stockInOutDetailDTO = 
                        出入库Service.scrapGarment(this.barcode, mnemonic);
                    //  重新下单
                    new Form套号销售样衣下单(this.barcode).ShowDialog();
                    MessageBox.Show("操作完成");
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.Message);
                }
                this.Close();
            }
        }
    }
}